import Vue from 'vue'
import Router from 'vue-router'

import index from '~/pages/index'
import webIndex from '~/pages/web/index'

import list from '~/pages/list'
import webList from '~/pages/web/list'

Vue.use(Router)

export function createRouter(
  ssrContext,
  createDefaultRouter,
  routerOptions,
  config,
  store
) {
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/',
        name: 'home',
        component: {
          render: (h) => {
            console.log('我是动态的', config)
            switch (config._app.platform) {
              case 'mobile':
                return h(index)
              default:
                return h(webIndex)
            }
          }
        }
      },
      {
        path: '/list',
        name: 'list',
        component: {
          render: (h) => {
            console.log('我是动态的', config)
            switch (config._app.platform) {
              case 'mobile':
                return h(list)
              default:
                return h(webList)
            }
          }
        }
      }
    ],
  })
}
